

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import br.ufc.storm.Control.DBHandler;
import br.ufc.storm.Control.FunctionHandler;
import br.ufc.storm.Control.XMLHandler;
import br.ufc.storm.Model.QualityParameter;
import br.ufc.storm.jaxb.AbstractComponentType;
import br.ufc.storm.jaxb.ContextContract;
import br.ufc.storm.jaxb.ContextParameterType;

public class Main {

	public static void main(String[] args) {
		
//		List<ContextContract> abs = XMLHandler.resolve(new File("context_contract_example.xml"));
//		System.out.println(abs.size());
		
		/*List<ContextParameterType> l = DBHandler.getContextParameter(1);
		for(ContextParameterType p: l){f
			System.out.println(p.getName());
		}*/
		
	/*	AbstractComponentType ac = DBHandler.getAbstractComponent(1);
		System.out.println(ac.getName());
		for(ContextParameterType p: ac.getContextParameter()){
			System.out.println(p.getName());
			System.out.println(p.getBound().getContextParameter().size());
			if(p.getBound().getContextParameter().size()>0){
				System.out.println("Size kkk...: "+p.getBound().getContextParameter().size());
			}
		}*/

	
		
		
		
		/*AbstractComponentType x = new AbstractComponentType();
		x.setName("Wagner");
		x.setKind("0");
		x.setIdAc(15);
		
		XMLHandler.JavaToXML(x);*/
		//System.out.println(XMLHandler.listComponent());
//		System.out.println(XMLHandler.getContextParameters("OPTERON"));
		//System.out.println(DBHandler.getAbstractComponentName(23));
		
		//System.out.println(DBHandler.getContextContract(15).getCcName());
		/*List<ContextContract> list  = DBHandler.generateCandidates(1, 31);
		for(ContextContract i: list){
			System.out.println("Ahhhh: "+i.getCcName());
		}*/
		
/*		ArrayList<String> vec = new ArrayList<String>();
		vec.add("5");
		vec.add("2");
		vec.add("20");
		String f = "?^2+2*?+?";
		System.out.println(QualityParameter.evaluateQualityParameter(null,vec,f));
*/		
		
		/*AbstractComponentType act = new AbstractComponentType();
		act.setName("Joao");
		act.setKind("1");
		
		XMLHandler.JavaToXML(act);*/
		
		//XMLHandler.addAbstractComponentFromXML(new File ("blablabla2.xml"));
		
		//System.out.println(XMLHandler.getAbstractComponent("I7"));
		
		//####################################################################
		ContextContract cc = new ContextContract();
		AbstractComponentType ac = new AbstractComponentType();
		ac.setIdAc(26);
		cc.setAbstractComponent(ac);
		AbstractComponentType ad = new AbstractComponentType();
		ad.setIdAc(1);
		cc.getAbstractComponent().setSupertype(ad);
		List<ContextContract> resolve = DBHandler.resolve(cc);
		for(ContextContract a:resolve){
			System.out.println("Candidato: "+a.getAbstractComponent().getIdAc());
		}
		
		
/*
		ContextContract cc = new ContextContract();
		AbstractComponentType ac = new AbstractComponentType();
		ac.setIdAc(26);
		cc.setAbstractComponent(ac);
		AbstractComponentType ad = new AbstractComponentType();
		ad.setIdAc(1);
		cc.getAbstractComponent().setSupertype(ad);
		List<ContextContract> resolve = DBHandler.resolve(cc);
		//System.out.println(resolve.size());
		for(ContextContract a:resolve){
			System.out.println("Candidato: "+a.getAbstractComponent().getIdAc());
		}
		
		
		
		List<ContextParameterType> t = DBHandler.getContextParameter(14);
		for(ContextParameterType x: t){
			System.out.println("AAAAA:"+x.getName());
		}
		*/
		
		
	
		
	}
}
